package vn.ikame.android.adapter;

import java.util.ArrayList;

import vn.ikame.android.object.Category;
import vn.ikame.android.truyenf17voz.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.loopj.android.image.SmartImageView;

public class GridViewAdapter extends BaseAdapter {

	private Context mContext;
	private LayoutInflater mLayoutInflater;
	private ArrayList<Category> mCate;

	public GridViewAdapter(Context context, ArrayList<Category> clips) {
		mContext = context;
		mCate = clips;
	}

	public int getCount() {
		return mCate.size();
	}

	public Category getItem(int position) {
		return mCate.get(position);
	}

	public long getItemId(int position) {
		return mCate.get(position).getId();
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mLayoutInflater.inflate(R.layout.maingridview, null);
			
			((TextView) convertView.findViewById(R.id.main_gv_item_name)).setText(mCate.get(position).getName());
			((SmartImageView) convertView.findViewById(R.id.main_gv_item_frame)).setImageUrl(mCate.get(position).getImg());
			
		}

		return convertView;
	}

}
